package com.zyf.controller;

import com.zyf.common.result.Result;
import com.zyf.service.OssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/** oss文件上传 控制层
 * @author zyf
 * @date 2021年05月21日 14:53
 */
@Api("文件上传")
@RestController
@RequestMapping("/api/oss/file")
public class OssApiController {

    @Autowired
    private OssService ossService;

    @ApiOperation(value = "上传文件到阿里云oss")
    @PostMapping("/fileUpload")
    public Result fileUpload(MultipartFile file){
        String fileUrl = ossService.upload(file);
        return Result.ok(fileUrl);
    }

}
